<?php

namespace App\Http\Requests\Api;

class ResumeWorkExpRequest extends ApiRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'id' => $this->is('*/update') ? 'bail|required|integer' : '',
            'resume_id' => $this->is('*/create') ? 'bail|required|integer' : '',
            'company' => 'required',
            'industry' => 'bail|required|integer',
            'comkind' => 'bail|required|integer',
            'scale' => 'bail|required|integer',
            'starttime' => 'bail|required|before:now',
            'endtime' => 'bail|required' . ($this->endtime == '0000-00-00' ? '' : '|after:starttime'),
            'post' => 'required',
        ];
    }

    /*
     * 字段描述
     */
    public function attributes()
    {
        return [
            'company' => '公司名称',
            'industry' => '所属行业',
            'comkind' => '公司性质',
            'scale' => '公司规模',
            'starttime' => '入职时间',
            'endtime' => '离职时间',
            'post' => '职位名称',
            'content' => '工作描述',
        ];
    }

    public function messages()
    {
        return array_merge(parent::messages(),[
            'starttime.before'=>':attribute不能小于现在',
            'endtime.after' => '开始时间不能小于结束时间'
        ]);
    }
}
